<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>echarts</title>
    <style>
      .container {
        width: 800px;
        height: 400px;
      }
    </style>
  </head>
  <body>
    <div class="container"></div>
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.0/dist/echarts.min.js"></script>
    <script>
      const myEcharts = echarts.init(document.querySelector(".container"));
      const option = {
        dataset: {
          source: [
            ["一月", 11, 22, "xx", 11],
            ["二月", 21, 31, "yy", 22],
            ["三月", 33, 42, "zz", 33],
            ["四月", 25, 24],
            ["五月", 11, 22],
            ["六月", 21, 31],
            ["七月", 33, 42],
            ["八月", 25, 24],
            ["九月", 11, 22],
            ["十月", 21, 31],
            ["十一月", 33, 42],
            ["十二月", 25, 26],
          ],
        },
        xAxis: {
          type: "category",
        },
        yAxis: {},
        tooltip: {},
        // 图例：显示隐藏图表
        legend: {
          data: ["柱形图", "折线图", "饼图"],
        },
        series: [
          {
            name: "柱形图",
            type: "bar",
            encode: { x: 0, y: 1 },
          },
          {
            name: "折线图",
            type: "line",
            encode: { x: 0, y: 2 },
          },
          {
            name: "饼图",
            type: "pie",
            // 半径
            radius: [0, 30],
            // 圆心点坐标
            center: [650, 40],
            encode: {
              itemName: 3,
              value: 4,
            },
          },
        ],
      };
      myEcharts.setOption(option);
    </script>
  </body>
</html>
